/**
 * output package name
 */
package com.kingdee.eas.custom.bscc.report.client;

import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.swing.tree.DefaultKingdeeTreeNode;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.base.core.util.EmptyUtil;
import com.kingdee.eas.basedata.assistant.AccountPropertyCollection;
import com.kingdee.eas.basedata.assistant.AccountPropertyFactory;
import com.kingdee.eas.basedata.assistant.CurrencyFactory;
import com.kingdee.eas.basedata.assistant.CurrencyInfo;
import com.kingdee.eas.basedata.assistant.ICurrency;
import com.kingdee.eas.basedata.org.CompanyOrgUnitCollection;
import com.kingdee.eas.basedata.org.CompanyOrgUnitFactory;
import com.kingdee.eas.basedata.org.OrgStructureInfo;
import com.kingdee.eas.basedata.org.client.f7.NewCompanyF7;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.fi.cas.CashHelper;
import com.kingdee.eas.fi.gl.GlUtils;
import com.kingdee.eas.fm.common.AccessHelper;
import com.kingdee.eas.fm.common.FMHelper;
import com.kingdee.eas.fm.common.client.FMClientHelper;
import com.kingdee.eas.fm.fs.InAcctFactory;
import com.kingdee.eas.fm.fs.client.FSClientHelper;
import com.kingdee.eas.fm.fs.client.InAcctBalanceparam;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.EASResource;
import com.kingdee.eas.util.client.MsgBox;
/**
 * output class name
 */
public class InAcctBalanceFilterUI extends AbstractInAcctBalanceFilterUI
{
    private static final Logger logger = CoreUIObject.getLogger(InAcctBalanceFilterUI.class);
    
    /**
     * output class constructor
     */
    public InAcctBalanceFilterUI() throws Exception
    {
        super();
    }
    public void loadFields()
    {













/*  69*/        super.loadFields();
    }
    public void storeFields()
    {




/*  77*/        super.storeFields();
    }
    protected void chkIA_actionPerformed(java.awt.event.ActionEvent e)
        throws Exception
    {



/*  85*/        super.chkIA_actionPerformed(e);
    }
    protected void btnCompanySelect_actionPerformed(java.awt.event.ActionEvent e)
        throws Exception
    {



/*  93*/        super.btnCompanySelect_actionPerformed(e);
    }
    public Object getParam()
    {/*  96*/        InAcctBalanceparam para = new InAcctBalanceparam();
/*  97*/        para.setCompanyIds(getCompanyIds());
/*  98*/        para.setCurrencyId(((CurrencyInfo)comboCurrency.getSelectedItem()).getId().toString());
/*  99*/        para.setRptDate((Date)pkRptDate.getValue());
/* 100*/        para.setIncludeClose(chkIncludeClose.isSelected());
/* 101*/        para.setShowTotal(chkIsShowTotal.isSelected());


/* 104*/        para.setShowLargeZero(chkIsShowLargeZero.isSelected());
/* 105*/        para.setAccountPropertyIds(AccessHelper.getF7Ids(prmtAccountProperty));

/* 107*/        return para;
    }
    public void setParam(Object param)
    {/* 110*/        if(EmptyUtil.isEmpty(param))
/* 111*/            return;

/* 113*/        InAcctBalanceparam para = (InAcctBalanceparam)param;



/* 117*/        try
        {
/* <-MISALIGNED-> */ /* 117*/            if(!EmptyUtil.isEmpty(para.getCurrencyId()))
            {
/* <-MISALIGNED-> */ /* 118*/                ICurrency iCurrency = CurrencyFactory.getRemoteInstance();
/* <-MISALIGNED-> */ /* 119*/                CurrencyInfo currencyInfo = iCurrency.getCurrencyInfo(new ObjectUuidPK(para.getCurrencyId()));
/* <-MISALIGNED-> */ /* 121*/                FMClientHelper.setSelectObject(comboCurrency, currencyInfo);
            }
        }
/* <-MISALIGNED-> */ /* 123*/        catch(BOSException e)
        {
/* <-MISALIGNED-> */ /* 124*/            handUIException(e);
/* <-MISALIGNED-> */ /* 125*/            SysUtil.abort();
        }
/* <-MISALIGNED-> */ /* 126*/        catch(EASBizException e)
        {
/* <-MISALIGNED-> */ /* 127*/            handUIException(e);
/* <-MISALIGNED-> */ /* 128*/            SysUtil.abort();
        }
/* <-MISALIGNED-> */ /* 130*/        setCompanyIds(para.getCompanyIds());
/* <-MISALIGNED-> */ /* 131*/        pkRptDate.setValue(para.getRptDate());
/* <-MISALIGNED-> */ /* 132*/        chkIncludeClose.setSelected(para.isIncludeClose());
/* <-MISALIGNED-> */ /* 133*/        chkIsShowTotal.setSelected(para.isShowTotal());
/* <-MISALIGNED-> */ /* 136*/        chkIsShowLargeZero.setSelected(para.isShowLargeZero());
/* <-MISALIGNED-> */ /* 137*/        if(!FMHelper.isEmpty(para.getAccountPropertyIds()))
        {
/* <-MISALIGNED-> */ /* 138*/            java.util.Set set = FMHelper.asSet(para.getAccountPropertyIds());
/* <-MISALIGNED-> */ /* 139*/            EntityViewInfo ev = new EntityViewInfo();
/* <-MISALIGNED-> */ /* 140*/            FilterInfo filter = new FilterInfo();
/* <-MISALIGNED-> */ /* 141*/            filter.getFilterItems().add(new FilterItemInfo("id", set, CompareType.INCLUDE));
/* <-MISALIGNED-> */ /* 143*/            ev.setFilter(filter);
/* <-MISALIGNED-> */ /* 145*/            try
            {
/* <-MISALIGNED-> */ /* 145*/                AccountPropertyCollection coll = AccountPropertyFactory.getRemoteInstance().getAccountPropertyCollection(ev);
/* <-MISALIGNED-> */ /* 147*/                prmtAccountProperty.setData(((Object) (coll.toArray())));
            }
/* <-MISALIGNED-> */ /* 148*/            catch(BOSException e)
            {
/* <-MISALIGNED-> */ /* 149*/                handUIException(e);
/* <-MISALIGNED-> */ /* 150*/                SysUtil.abort();
            }
        }
    }
    protected void init()
        throws Exception
    {
/* <-MISALIGNED-> */ /* 158*/        super.init();
/* <-MISALIGNED-> */ /* 159*/        pkRptDate.setSupportedEmpty(false);
/* <-MISALIGNED-> */ /* 161*/        EntityViewInfo evi = new EntityViewInfo();
/* <-MISALIGNED-> */ /* 162*/        evi.getSelector().add("id");
/* <-MISALIGNED-> */ /* 163*/        CompanyOrgUnitCollection coll = CompanyOrgUnitFactory.getRemoteInstance().getCompanyOrgUnitCollection(evi);
/* <-MISALIGNED-> */ /* 165*/        setCompanyIdSet(AccessHelper.getIds(coll.toArray()));
/* <-MISALIGNED-> */ /* 166*/        clear();
    }
    protected void initCompanyState()
    {
/* <-MISALIGNED-> */ /* 170*/        super.initCompanyState();
/* <-MISALIGNED-> */ /* 171*/        if(FSClientHelper.isClearingHouseCompanyId((String)null))
        {
/* <-MISALIGNED-> */ /* 172*/            chkIA.setEnabled(true);
/* <-MISALIGNED-> */ /* 173*/            btnCompanySelect.setEnabled(true);
/* <-MISALIGNED-> */ /* 174*/            btnCompanySelect.setVisible(true);
        }
    }
    private void initCompany()
        throws EASBizException, BOSException
    {



/* 187*/        if(GlUtils.isCompanyUnion(currentCompany) || currentCompany.getId().toString().equals(FSClientHelper.getClearingHouseCompany().getId().toString()))
        {

/* 190*/            CompanyOrgUnitCollection coll = InAcctFactory.getRemoteInstance().getInAcctApplyCompany();
/* 191*/            List list = new ArrayList();
/* 192*/            for(int i = 0; i < coll.size(); i++)
/* 193*/                list.add(coll.get(i));

/* 195*/            setCompanyIds(AccessHelper.getIds(((Object) (list.toArray()))));
        } else
        {/* 197*/            setCompanyIds(new String[] {/* 197*/                currentCompany.getId().toString()
            });
        }
    }
    private void popNode(List list, DefaultKingdeeTreeNode root)
    {
        DefaultKingdeeTreeNode node;



/* 207*/        for(Enumeration c = root.children(); c.hasMoreElements(); popNode(list, node))
        {/* 208*/            node = (DefaultKingdeeTreeNode)c.nextElement();
/* 209*/            if(node.isCheckBoxEnabled())
            {/* 210*/                OrgStructureInfo org = (OrgStructureInfo)node.getUserObject();
/* 211*/                com.kingdee.eas.basedata.org.FullOrgUnitInfo fullUnit = org.getUnit();
/* 212*/                list.add(fullUnit);
            }
        }
    }
    public void clear()
    {



/* 221*/        pkRptDate.setValue(new Date());
/* 222*/        CashHelper.initCombCurrency(comboCurrency, false);
/* 223*/        chkIncludeClose.setSelected(false);
/* 224*/        chkIsShowTotal.setSelected(false);

/* 226*/        try
        {
/* <-MISALIGNED-> */ /* 226*/            initCompany();
        }
/* <-MISALIGNED-> */ /* 227*/        catch(EASBizException e)
        {
/* <-MISALIGNED-> */ /* 228*/            handUIException(e);
/* <-MISALIGNED-> */ /* 229*/            SysUtil.abort();
        }
/* <-MISALIGNED-> */ /* 230*/        catch(BOSException e)
        {
/* <-MISALIGNED-> */ /* 231*/            handUIException(e);
/* <-MISALIGNED-> */ /* 232*/            SysUtil.abort();
        }
/* <-MISALIGNED-> */ /* 234*/        super.clear();
    }
    protected void companyValueChange(Object object)
        throws Exception
    {
/* <-MISALIGNED-> */ /* 237*/        Object array[] = (Object[])(Object[])object;
/* <-MISALIGNED-> */ /* 239*/        Object result[] = FMClientHelper.removeVirtualCompany(array);
/* <-MISALIGNED-> */ /* 241*/        super.companyValueChange(((Object) (result)));
    }
    protected NewCompanyF7 getNewCompanyF7()
    {
/* <-MISALIGNED-> */ /* 245*/        if(FSClientHelper.isCHUser())
/* <-MISALIGNED-> */ /* 247*/            try
            {
/* <-MISALIGNED-> */ /* 247*/                return super.getAllCompanyOrg();
            }
/* <-MISALIGNED-> */ /* 248*/            catch(Exception e)
            {
/* <-MISALIGNED-> */ /* 249*/                handUIException(e);
            }
/* <-MISALIGNED-> */ /* 252*/        return super.getNewCompanyF7();
    }
    public boolean verify()
    {
/* <-MISALIGNED-> */ /* 259*/        Date rptDate = (Date)pkRptDate.getValue();
/* <-MISALIGNED-> */ /* 260*/        Date openDate = null;
/* <-MISALIGNED-> */ /* 262*/        try
        {
/* <-MISALIGNED-> */ /* 262*/            openDate = FSClientHelper.getClearingHouse().getOpenDate();
        }
/* <-MISALIGNED-> */ /* 263*/        catch(EASBizException e)
        {
/* <-MISALIGNED-> */ /* 264*/            handUIException(e);
/* <-MISALIGNED-> */ /* 265*/            SysUtil.abort();
        }
/* <-MISALIGNED-> */ /* 266*/        catch(BOSException e)
        {
/* <-MISALIGNED-> */ /* 267*/            handUIException(e);
/* <-MISALIGNED-> */ /* 268*/            SysUtil.abort();
        }
/* <-MISALIGNED-> */ /* 270*/        if(rptDate.before(openDate))
        {
/* <-MISALIGNED-> */ /* 271*/            MsgBox.showWarning(this, EASResource.getString("com.kingdee.eas.fm.fs.SettlementBillUI", "MustBigOpenDate"));
/* <-MISALIGNED-> */ /* 272*/            return false;
        } else
        {
/* <-MISALIGNED-> */ /* 274*/            return super.verify();
        }
    }
    protected void setDefaultValue()
    {
/* <-MISALIGNED-> */ /* 277*/        super.setDefaultValue();
/* <-MISALIGNED-> */ /* 279*/        prmtAccountProperty.setValue(null);
/* <-MISALIGNED-> */ /* 280*/        chkIsShowLargeZero.setSelected(false);
    }
    protected Class getParamClass()
    {
/* <-MISALIGNED-> */ /* 290*/        return com.kingdee.eas.fm.fs.client.InAcctBalanceparam.class;
    }


}